#include "stdafx.h"
#include "Viewport.h"
#include "WindowTarget.h"

CViewport::CViewport(CWindowTarget* pParentWindow)
		: m_pParentWindow(pParentWindow)
{

}

CViewport::~CViewport()
{
	m_pParentWindow->DeleteViewport(this);
}


void	CViewport::SetRect(const RECT& rect)
{
	RECT tRect;
	if(m_pParentWindow)
	{		
		m_pParentWindow->GetRect(tRect);
		tRect.top	= max(rect.top,tRect.top);
		tRect.left	= max(rect.left,tRect.left);
		tRect.right	= min(rect.right,tRect.right);
		tRect.bottom= min(rect.bottom,tRect.bottom);
	}
	else
	{
		tRect = rect;
	}
	tRect.right = max(tRect.left, tRect.right);
	tRect.bottom= max(tRect.top,tRect.bottom);
}